
package instrumentation;

import java.io.Serializable;
import java.util.BitSet;
import java.util.HashSet;
import java.util.Set;



public class Data implements Serializable, Value {

	private static final long serialVersionUID = -4042773236943535616L;

	private final int id;
	private static int idGenerator = 0;

	private final String fieldName;

	private final Set<DataUse> uses ;



	private boolean field;
	private final boolean param;
	private final int indxParam;
	private final String type;
	private String value;
	public Data(String fieldName,String type, int indxParam,boolean param) {
		id = idGenerator++;
		this.indxParam=indxParam;
		this.param = param;
		this.fieldName = fieldName;
		field = fieldName != null;
		this.type=type;
		uses = new HashSet<DataUse>();

	}

	public int getId() {
		return id;
	}

	public String getFieldName() {
		return fieldName;
	}
	public String getType() {
		return type;
	}

	void setField(boolean field) {
		this.field = field;
	}

	public boolean isField() {
		return field;
	}

	public boolean isParam() {
		return param;
	}
	public int getIndxParam() {
		return indxParam;
	}

	public String getValue() {
		return value;
	}
	public void setValue(String v) {
		value=v;
	}


	@Override
	public String toString() {
		if(param) return getType()+ " p" + getIndxParam();
		if(field) return getType()+ " " +getFieldName();
		return "d" + id;
	}
}
